
<template>
    <rx-dialog @handOk="handleSubmit" @cancel="cancel">
        <rx-layout>
            <div slot="center">
                <a-form-model ref="form"  :model="mdl" :rules="rules" :label-col="labelCol" :wrapper-col="wrapperCol">
                  <a-row>
                    <a-col :span="12">
                      <a-form-model-item  :label="i18n('form.name','名称')" prop = "name">
                        <a-input :placeholder="i18n('form.name','名称','input')" v-model="mdl.name"/>
                      </a-form-model-item>
                    </a-col>
                    <a-col :span="12">
                      <a-form-model-item  :label="i18n('form.key','标识')" prop = "key">
                        <a-input :placeholder="i18n('form.key','请输入标识','input')" v-model="mdl.key"/>
                      </a-form-model-item>
                    </a-col>
                  </a-row>
                  <a-row>
                    <a-col :span="24">
                      <a-form-model-item  :label="i18n('form.enabled','是否启用')" prop = "enabled" :label-col="labelCol1" :wrapper-col="wrapperCol1">
                        <a-switch v-model="enabled"/>
                      </a-form-model-item>
                    </a-col>
                  </a-row>
                </a-form-model>
            </div>
        </rx-layout>
    </rx-dialog>
</template>
<script>
    import FormCodegenFileTemplateApi from '@/api/form/codegen/formCodegenFileTemplate'
    import {RxDialog,BaseFormModel} from "@lowcode/jpaas-common-lib";


    export default {
        name: 'FormCodegenFileTemplateEdit',
        mixins:[BaseFormModel],
        components: {
            RxDialog,
        },
        data(){
            return {
              enabled: false,
              rules: {
                name: [{required: true, message: this.i18n('form.name','请输入名称','input'), trigger: 'change'}],
                key: [{required: true, message: this.i18n('form.key','请输入标识','input') , trigger: 'change'}],
                enabled: [{required: false, message: this.i18n('form.enabled','请输入是否启用','input'), trigger: 'change'}]
              }
            }
        },
        methods: {
          i18n(name,text,key){
            return this.$ti18(name,text,"formCodegenFileTemplate",key);
          },
          onload_(data) {
            if (data) {
              this.enabled = data.enabled == 'YES' ? true : false;
            }
          },
          get(id) {
            return FormCodegenFileTemplateApi.get(id);
          },
          save() {
            this.mdl.enabled=this.enabled?'YES':'NO';
            return FormCodegenFileTemplateApi.save(this.mdl);
          }
        }
    }
</script>
<style>
    .relick a{
        margin-right: 10px;
    }

</style>
